public class J111202 {
    public static class myThread implements Runnable{
        @Override
        public void run() {
            for (int i = 0; i < 20; i++) {
                int finalI = i;
                Thread t = new Thread(() -> System.out.println("Thread" + finalI), "子线程");
                t.start();
                try {
                    t.join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
    public static void main(String[] args) throws InterruptedException {
        Runnable mythread = new myThread();
        Thread t = new Thread(mythread, "主线程");
        t.start();
        t.join();
        System.out.println("ok");
    }
}
